//
//  RequestManager.h
//  片刻
//
//  Created by lanou3g on 15/6/4.
//  Copyright (c) 2015年 韩亚伟. All rights reserved.
//

#import <Foundation/Foundation.h>

//定义枚举
typedef NS_ENUM(NSInteger, RequestModel){
    POST,
    GET
};
@class RequestManager;
@protocol RequestDelegate <NSObject>

//请求完毕让代理对象执行的方法，同时把完整得data传给代理对象
- (void)requestDidFinishWithData:(NSData *)data;

//请求失败后把错误原因传给代理对象
- (void)requestError:(NSError *)error;

@optional
- (void)requestDidFinishWithData:(NSData *)data requestManager:(RequestManager *)requestManager;
@end

@interface RequestManager : NSObject<NSURLConnectionDataDelegate>

@property(nonatomic,retain) NSString *requestURL;   //请求网址

@property(nonatomic,retain) NSString *requestParameter;     //请求参数

@property(nonatomic,retain) NSMutableDictionary *parameterDict;     //请求参数字典

@property(nonatomic,assign) RequestModel requestModel;     //请求类型

@property(nonatomic,retain) NSMutableData *data;            //接受返回的data

@property(nonatomic,assign) id<RequestDelegate> delegate;   //保存代理对象
//初始化方法
- (instancetype)initWithRequestURL:(NSString *)urlString requestModel:(RequestModel)requestModel parameter:(NSString *)parameter;

//开始请求
- (void)startRequest;

@end


































